package com.css.fxfzaqbz.modules.data.service.impl;

import com.css.fxfzaqbz.constants.YNEnum;
import com.css.fxfzaqbz.modules.data.entity.DisposeLabel;
import com.css.fxfzaqbz.modules.data.repository.DisposeLabelRepository;
import com.css.fxfzaqbz.modules.data.service.DisposeLabelService;
import com.css.fxfzaqbz.modules.supergraph.exception.CustomException;
import com.css.fxfzaqbz.util.PlatformDateUtils;
import com.css.fxfzaqbz.util.PlatformSessionUtils;
import com.css.fxfzaqbz.util.UUIDGenerator;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class DisposeLabelServiceImpl implements DisposeLabelService {


    @Resource
    DisposeLabelRepository disposeLabelRepository;



    @Override
    public void saveDisposeLabel(DisposeLabel disposeLabel) {
        List<DisposeLabel> labels = disposeLabelRepository.getByLabels(disposeLabel.getLabel());
        if (labels.size()!=0){
            throw new CustomException("该子标签已存在,请勿重复添加");
        }
        disposeLabel.setId(UUIDGenerator.getUUID());
        disposeLabel.setDelFlag(YNEnum.N.toString());
        disposeLabel.setCreateUser(PlatformSessionUtils.getUserId());
        disposeLabel.setCreateTime(PlatformDateUtils.getCurrentTimestamp());
        disposeLabelRepository.saveDisposeLabel(disposeLabel);
    }

    @Override
    public void delDisposeLabel(List<String> ids) {
        disposeLabelRepository.delDisposeLabel(ids);
    }

    @Override
    public Map<String, Object> getDisposeAllLabel(Integer curPage, Integer pageSize,DisposeLabel disposeLabel) {
        return disposeLabelRepository.getDisposeAllLabel(curPage,pageSize,disposeLabel);
    }


}
